import 'dart:convert';

import 'package:dio/dio.dart';
import 'package:flutter/cupertino.dart';
import 'package:mfkb/config/Config.dart';
import 'package:mfkb/util/HttpUtil.dart';

class SchoolService {
  Dio dio = new Dio() ;
  
  Future<dynamic> getData() async{
    dynamic model ;
    try {
      Response data = await dio.get(Config().getHost()+"/api/v1/schoolList") ;
      model = data.data ;
    } catch (e) {
      model = {"code":500 , "msg":"网络错误" , "data":""} ;
    }
    return model ;
  }

  // 获取周边店铺数据
  Future<dynamic> aroundMarkets(int page) async{
    dynamic data ;
    try {
      data = await HttpUtil().get(Config().getHost()+"/api/admin/v1/markets?page="+page.toString()) ;
    } catch (e) {
      data = {"code":500 , "msg":"网络错误" , "data":""} ;
    }
    return data ;
  }

  // 根据id获取周边店铺的详细信息
  Future<dynamic> aroundMarket(int id) async{
    dynamic data ;
    try {
      data = await HttpUtil().get(Config().getHost()+"/api/admin/v1/market?id="+id.toString()) ;
    } catch (e) {
      data = {"code":500 , "msg":"网络错误" , "data":""} ;
    }
    return data ;
  }

  // 获取周边兼职数据
  Future<dynamic> aroundJobs(int page) async{
    dynamic data ;
    try {
      data = await HttpUtil().get(Config().getHost()+"/api/admin/v1/jobs?page="+page.toString()) ;
    } catch (e) {
      data = {"code":500 , "msg":"网络错误" , "data":""} ;
    }
    return data ;
  }

  // 根据id获取周边店铺的详细信息
  Future<dynamic> aroundJob(int id) async{
    dynamic data ;
    try {
      data = await HttpUtil().get(Config().getHost()+"/api/admin/v1/job?id="+id.toString()) ;
    } catch (e) {
      data = {"code":500 , "msg":"网络错误" , "data":""} ;
    }
    return data ;
  }

  // 获取周边兼职数据
  Future<dynamic> aroundHouses(int page) async{
    dynamic data ;
    try {
      data = await HttpUtil().get(Config().getHost()+"/api/admin/v1/houses?page="+page.toString()) ;
    } catch (e) {
      data = {"code":500 , "msg":"网络错误" , "data":""} ;
    }
    return data ;
  }

  // 根据id获取周边店铺的详细信息
  Future<dynamic> aroundHouse(int id) async{
    dynamic data ;
    try {
      data = await HttpUtil().get(Config().getHost()+"/api/admin/v1/house?id="+id.toString()) ;
    } catch (e) {
      data = {"code":500 , "msg":"网络错误" , "data":""} ;
    }
    return data ;
  }

  Future<dynamic> init() async{
    dynamic data ;
    try {
      data = await HttpUtil().get(Config().getHost()+"/api/admin/v1/schoolInit") ;
    } catch (e) {
      data = {"code":500 , "msg":"网络错误" , "data":""} ;
    }
    return data ;
  }

  Future<dynamic> checkSchool() async{
    dynamic data ;
    try {
      data = await HttpUtil().get(Config().getHost()+"/api/admin/v1/checkSchool") ;
    } catch (e) {
      data = {"code":500 , "msg":"网络错误" , "data":""} ;
    }
    return data ;
  }
}